package com.wanda.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wanda.model.JsonModelGeneral;

import com.wanda.service.Wd_FunctionService;

@Controller
@RequestMapping(value="/function")
public class Wd_FunctionController {
                
	@Autowired
	private Wd_FunctionService wd_FunctionService;
     
	@RequestMapping(value="/selectById")
    public @ResponseBody Map<String,Object> selectById(String id){
    	Map<String,Object> map = new HashMap<String,Object>(); 
    	map.put("date", wd_FunctionService.selectById(id));
	///json.setRows(wd_FunctionService.selectById(id));
		return map;
    ///	return  wd_FunctionService.selectById(id);
    }
    
	@RequestMapping(value="/selectAll")      
    public @ResponseBody JsonModelGeneral selectAll(){

    	JsonModelGeneral json = new JsonModelGeneral();
		json.setRows(wd_FunctionService.selectAll());
		return json;
    }
	
	
	
	@RequestMapping(value="/selectbyfunction")      
    public @ResponseBody JsonModelGeneral selectbyfunction(HttpServletRequest request,String function1){
		String function= request.getParameter("function1");
		System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+function1);
		System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"+function);
		//function="%"+function+"%";
    	JsonModelGeneral json = new JsonModelGeneral();
		json.setRows(wd_FunctionService.selectByFunction(function));
		return json;
    }

}
